﻿
@{
    ViewBag.Title = "Index";
}

<fieldset style="margin-top: 30px;">
    <legend>主页</legend>

    <link rel="stylesheet" type="text/css" href="~/Views/Messages/Index.css" />
    <script type="text/javascript">
        function goto() {
            var a = document.getElementById("txtInputNumber").value;
            var url = "/Messages/Index?currentPage=" + a;
            location.href = url;
        }
    </script>

    @using (Html.BeginForm("Index", "Messages", FormMethod.Get))
    {
        <p>
            留言类型:@Html.DropDownList("messageType", "all")
            留言主题:@Html.TextBox("SearchString")
            <input type="submit" class="btn btn-sm btn-success" value="查询" />
        </p>
    }
    <br />
    @model IEnumerable<Message_Board.Models.Message>
    <table class="table table-striped" width="100%">
        <tr>
            <th> 留言主题 </th>
            <th> 留言类型 </th>
            <th> 留言者 </th>
            <th> 留言时间 </th>
            <th> <a href="/Messages/Create">创建一个新的主题</a> </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td> <label><a href="/Messages/Details?subject=@item.Subject">@item.Subject</a> </label> </td>
                <td> <label>@item.MessageType </label> </td>
                <td> <label>@item.UserName</label> </td>
                <td> <label>@item.Time</label> </td>
            </tr>  }
    </table>
    <div class="container" style="text-align: center; border:none">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin: 0;">
            <ul id="PagerID" class="pagination pagination-sm">
                <li><a href="/Messages/Index?currentPage=1">首页 </a></li>
                <li><a href="/Messages/Index?currentPage=@((int)ViewBag.currentPage - 1)">上页 </a></li>
                <li>
                    <span>
                        页:
                        <Label ID="lbCurrentPage" style="margin-bottom:0">@ViewBag.currentPage</Label>/<Label ID="lbMaxPage" style="margin-bottom:0">@ViewBag.maxPage</Label>
                    </span>
                </li>
                <li><a href="/Messages/Index?currentPage=@((int)ViewBag.currentPage + 1)">下页 </a></li>
                <li><a href="/Messages/Index?currentPage=@ViewBag.maxPage">末页 </a></li>
                <li><a onclick="goto()">GoTo </a></li>
                <li>
                    <input type="text" id="txtInputNumber" style="width: 50px;height:28px">
                </li>
            </ul>
        </div>
    </div>
</fieldset>